if (strcmp(cin + 2, "note") == 0) {
buff = gbfgetstr(fin);
if (buff == NULL) {
- buff = "";
+ buff = (char *) "";
}
line++;
cin = lrtrim(buff);
ARG_NOMINMAX
},
{"hint_at_end", &opt_hint_at_end, "If true, geocache hint at end of text", NULL, ARGTYPE_BOOL, ARG_NOMINMAX },
- {"gcsym", &opt_gcsym, "If set to 0, prefer user-provided symbols over Groundspeaks ones for geocaches", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, "1" },
+ {"gcsym", &opt_gcsym, "If set to 0, prefer user-provided symbols over Groundspeaks ones for geocaches", NULL, ARGTYPE_BOOL, ARG_NOMINMAX, (char *) "1" },
ARG_TERMINATOR
};
gbuint32
gt_color_value(const unsigned int garmin_index)
{
- if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
+ if ((garmin_index < GT_COLORS_CT)) {
return gt_colors[garmin_index].rgb;
} else {
return unknown_color; /* -1 */
const char*
gt_color_name(const unsigned int garmin_index)
{
- if ((garmin_index >= 0) && (garmin_index < GT_COLORS_CT)) {
+ if ((garmin_index < GT_COLORS_CT)) {
return gt_colors[garmin_index].name;
} else {
return gt_colors[0].name;
strcpy(openmode, mode);
if (strchr(mode, 'b') == NULL) {
- strncat(openmode, "b", sizeof(openmode));
+ strncat(openmode, "b", sizeof(openmode) - strlen(openmode) - 1);
}
if (self->is_pipe) {
int done = 0;
char* buf = (char*) xmalloc(MY_CBUF_SZ);
int result = 0;
- int extra;
while (!done) {
if (fd) {
- /*
- * The majority of this block (in fact, all but the
- * call to XML_Parse) are a disgusting hack to
- * correct defective GPX files that Geocaching.com
- * issues as pocket queries. They contain escape
- * characters as entities (�-) which makes
- * them not validate which croaks expat and torments
- * users.
- *
- * Look for '&' in the last maxentlength chars. If
- * we find it, strip it, then read byte-at-a-time
- * until we find a non-entity.
- */
- char* badchar;
- char* semi;
- int maxentlength = 8;
- len = gbfread(buf, 1, MY_CBUF_SZ - maxentlength, fd);
+ len = gbfread(buf, 1, MY_CBUF_SZ - 1, fd);
done = gbfeof(fd) || !len;
- buf[len] = '\0';
- if (len < maxentlength) {
- maxentlength = len;
- }
- badchar = buf+len-maxentlength;
- badchar = strchr(badchar, '&');
- extra = maxentlength - 1; /* for terminator */
- while (badchar && len < MY_CBUF_SZ-1) {
- semi = strchr(badchar, ';');
- while (extra && !semi) {
- len += gbfread(buf+len, 1, 1, fd);
- buf[len]='\0';
- extra--;
- if (buf[len-1] == ';') {
- semi= buf+len-1;
- }
- }
- badchar = strchr(badchar+1, '&');
- }
- {
- char hex[]="0123456789abcdef";
- badchar = strstr(buf, "&#x");
- while (badchar) {
- int val = 0;
- char* hexit = badchar+3;
- semi = strchr(badchar, ';');
- if (semi) {
- while (*hexit && *hexit != ';') {
- char hc = isalpha(*hexit) ? tolower(*hexit) : *hexit;
- val *= 16;
- val += strchr(hex, hc)-hex;
- hexit++;
- }
-
- if (val < 32) {
- warning(MYNAME ": Ignoring illegal character %s;\n\tConsider emailing %s at <%s>\n\tabout illegal characters in their GPX files.\n", badchar, gpx_author?gpx_author:"(unknown author)", gpx_email?gpx_email:"(unknown email address)");
- memmove(badchar, semi+1, strlen(semi+1)+1);
- len -= (semi-badchar)+1;
- badchar--;
- }
- }
- badchar = strstr(badchar+1, "&#x");
- }
- }
result = XML_Parse(psr, buf, len, done);
} else if (input_string) {
done = 0;
sl_float,
sl_double,
} sl_element;
+
+typedef enum {
+ fld_cadence,
+ fld_depth,
+ fld_heartrate,
+ fld_temperature,
+ fld_power
+} wp_field;
+
static void kml_mt_simple_array(const route_head* header,
const char* name,
- int offset, sl_element type)
+ wp_field member, sl_element type)
{
queue* elem, *tmp;
writer.writeStartElement("gx:SimpleArrayData");
QUEUE_FOR_EACH(&header->waypoint_list, elem, tmp) {
- char* datap = (char*) elem + offset;
+ waypoint* wpt = (waypoint *) elem;
+ char *datap;
+
+
+ switch (member) {
+ case fld_power:
+ datap = (char *) &wpt->power;
+ break;
+ case fld_cadence:
+ datap = (char *) &wpt->cadence;
+ break;
+ case fld_depth:
+ datap = (char *) &wpt->depth;
+ break;
+ case fld_heartrate:
+ datap = (char *) &wpt->heartrate;
+ break;
+ case fld_temperature:
+ datap = (char *) &wpt->temperature;
+ break;
+ default:
+ fatal("Bad member type");
+ }
switch (type) {
case sl_char: {
- char data = *(char*) datap;
+ signed char data = *(signed char*) datap;
writer.writeTextElement("gx:value", QString(data));
}
break;
writer.writeAttribute("schemaUrl", "#schema");
if (has_cadence)
- kml_mt_simple_array(header, kmt_cadence,
- offsetof(waypoint, cadence), sl_uchar);
+ kml_mt_simple_array(header, kmt_cadence, fld_cadence, sl_uchar);
if (has_depth)
- kml_mt_simple_array(header, kmt_depth,
- offsetof(waypoint, depth), sl_double);
+ kml_mt_simple_array(header, kmt_depth, fld_depth, sl_double);
if (has_heartrate)
- kml_mt_simple_array(header, kmt_heartrate,
- offsetof(waypoint, heartrate), sl_uchar);
+ kml_mt_simple_array(header, kmt_heartrate, fld_heartrate, sl_uchar);
if (has_temperature)
- kml_mt_simple_array(header, kmt_temperature,
- offsetof(waypoint, temperature), sl_float);
+ kml_mt_simple_array(header, kmt_temperature, fld_temperature, sl_float);
if (has_power)
- kml_mt_simple_array(header, kmt_power,
- offsetof(waypoint, power), sl_float);
+ kml_mt_simple_array(header, kmt_power, fld_power, sl_float);
writer.writeEndElement(); // Close SchemaData tag
writer.writeEndElement(); // Close ExtendedData tag
/* try to read to EOF (avoid determining file-size) */
static void *
-pdb_read_tail(gbfile *fin, gbuint32 *size)
+pdb_read_tail(gbfile *fin, gbint32 *size)
{
int count;
char buff[256];
fin->appinfo_len = gbfread(fin->appinfo, 1, top - offs, fin->file);
offs += fin->appinfo_len;
} else {
- gbuint32 size;
+ gbint32 size;
fin->appinfo = pdb_read_tail(fin->file, &size);
fin->appinfo_len = size;
offs += size;
typedef struct pdbrec_s {
gbuint32 offs;
- gbuint32 size;
+ gbint32 size;
gbuint32 id;
gbuint8 category;
gbuint8 flags;
time_t mtime; /* modification time */
time_t btime; /* backup time */
gbuint32 revision;
- gbuint32 appinfo_offs; /* offset to application info */
- gbuint32 index_offs; /* offset to sort-index info */
+ gbint32 appinfo_offs; /* offset to application info */
+ gbint32 index_offs; /* offset to sort-index info */
gbuint32 creator;
gbuint32 type;
gbuint32 uid;
double wppos_to_dec(char *value)
{
- if (strstr(value, "°") == NULL) {
+ if (strstr(value, "\xB0") == NULL) {
return atof(value);
} else {
int degrees, minutes;
sign = -1;
}
- sscanf(value, "%d°%d'%f\"", °rees, &minutes, &seconds);
+ sscanf(value, "%d\xB0%d'%f\"", °rees, &minutes, &seconds);
return sign * (degrees + ((float)minutes / 60) + (seconds / 3600));
}
}
unsigned int c, i, j, cs;
gbuint8 buffer[16];
- if (sector < 0 || sector > 0xFF) {
+ if (sector > 0xFF) {
fatal(MYNAME ": Invalid sector number (%i)\n", sector);
}
fatal(MYNAME ": Invalid sector number (%i)\n", first_sector);
}
be_write16(&MSG_LOG_READ_MULTI_SECTORS[1], first_sector);
- if (sector_count < 0 || sector_count > 0xFFFF) {
+ if (sector_count > 0xFFFF) {
fatal(MYNAME ": Invalid sector count (%i)\n", sector_count);
}
be_write16(&MSG_LOG_READ_MULTI_SECTORS[3], sector_count);
fatal(MYNAME ": You may specify only one of crosstrack, length, or relative.\n");
}
if (!xteopt && !lenopt && !relopt) {
- xteopt = "";
+ xteopt = (char *) "";
}
if (countopt) {
if (wpt->altitude != unknown_alt) {
xasprintf(&altout, " alt:%d", (int)((altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude));
} else {
- altout = "";
+ altout = (char *) "";
}
xasprintf(&tmpout2, "%s (%d%c %6.0f %7.0f)%s", tmpout1, utmz, utmzc, utme, utmn, altout);
gbfprintf(file_out, "%-16s %59s\n",
void
disp_vec_options(const char *vecname, arglist_t *ap)
{
- for (ap = ap; ap && ap->argstring; ap++) {
+ for (; ap && ap->argstring; ap++) {
if (*ap->argval && ap->argval) {
printf("options: module/option=value: %s/%s=\"%s\"",
vecname, ap->argstring, *ap->argval);
-char *xhtml_entities =
+const char *xhtml_entities =
"<!-- Portions (C) International Organization for Standardization 1986\n"
" Permission to copy in any form is granted for use with\n"
" conforming SGML systems and applications as defined in\n"